package com.hrt.datasender.datastorage;

import java.util.List;

import com.btcode.common.MyLog;
import com.btcode.log.ILog;
import com.hrt.datasender.datadao.service.BdSourceSingleService;
import com.hrt.datasender.datastorage.strategy.IStorageStrategy;
import com.hrt.datasender.datastorage.strategy.StrategyLoader;

public class StorageMain {

    private ILog log;

    /**
     * 存储模块总入口
     */
    public void start() {

        log = MyLog.getInstance().getLogger(StorageMain.class.getName());

        try {
            /**
             * 反射策略类
             */
            List<IStorageStrategy> strategyList = StrategyLoader.getInstance().loadAndGetStrategy();

            BdSourceSingleService.getInstance().clearRecord();

            /**
             * 遍历注册策略类
             */
            for (int i = 0; i < strategyList.size(); i++) {
                IStorageStrategy item = strategyList.get(i);
                item.init();
            }
            log.info("启动存储模块成功");
        }
        catch (Exception e) {
            log.error("启动存储模块出错", e);
        }

    }

}
